package com.naire.modul.kpi.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;
import com.naire.modul.kpi.service.KpiDeleteService;
import com.naire.modul.kpi.service.KpiEditorService;
import com.naire.modul.kpi.service.KpiFindService;
import com.naire.modul.kpi.service.KpiSearchService;
import com.naire.modul.kpi.vo.KpiVo;

public class KpiAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private KpiVo bean = new KpiVo();
	private List<KpiVo> list = new ArrayList<KpiVo>();
	private String dict_num;
	private String parent_code;

	public void jsonKpi() throws Exception {
		KpiSearchService service = new KpiSearchService();
		service.setDict_num(dict_num);
		service.setKpi_num(parent_code);
		service.invoke();
		json(service.getList());
	}

	public String search() throws Exception {
		KpiSearchService service = new KpiSearchService();
		service.setPageBean(pageBean);
		service.setDict_num(dict_num);
		service.setKpi_num(parent_code);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		KpiEditorService service = new KpiEditorService();
		service.setBean(bean);
		service.setParent_code(parent_code);
		service.setDict_num(dict_num);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		if (bean.getKpi_id() != null) {
			KpiFindService service = new KpiFindService();
			service.setId(bean.getKpi_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		KpiDeleteService service = new KpiDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public KpiVo getBean() {
		return bean;
	}

	public void setBean(KpiVo bean) {
		this.bean = bean;
	}

	public List<KpiVo> getList() {
		return list;
	}

	public void setList(List<KpiVo> list) {
		this.list = list;
	}

	public String getDict_num() {
		return dict_num;
	}

	public void setDict_num(String dict_num) {
		this.dict_num = dict_num;
	}

	public String getParent_code() {
		return parent_code;
	}

	public void setParent_code(String parent_code) {
		this.parent_code = parent_code;
	}

}
